<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <link href="../css/element.css" rel="stylesheet"/>
    <link href="../css/styleindex.css" rel="stylesheet"/>
    <style>
    .el-input__inner{
      border: 0;
      background-color: #E9E9E9;
    }.el-table th{
      background-color: #F2F9F6;
      text-align: center;
    }.el-table td{
      text-align: center;
    }
    </style>
</head>
<body style="background: #EFF0F4;">

  <div class="mui-content">
    <div id="vm" class="x-examok" v-cloak>
      <div class="x-ut-box">
        <div class="x-ut-top">
          <div class="x-ut-inp"><el-input v-model="searname" placeholder="请输入姓名"></el-input></div>
          <div class="x-ut-sear" @click="gosearch">搜索</div>
        </div>
        <div v-show="isshowall" @click="getdata();searname='';isshowall=false" class="x-ut-rebt">
          <span class="x-ut-reicon"></span>返回全部人员列表
        </div>
        <div class="x-ut-bot">
          <template>
            <el-table :data="tableData" style="width: 100%" @cell-click="godesc">
              <el-table-column prop="" label="序号" width="60" type="index"></el-table-column>
              <el-table-column prop="username" label="姓名" width=""></el-table-column>
              <el-table-column prop="create_date" label="添加时间" width=""></el-table-column>
            </el-table>
          </template>
        </div>
      </div>
    </div>
  </div>

  <script type="text/javascript" src="../script/vue.js"></script>
  <script type="text/javascript" src="../script/element.js"></script>
  <script type="text/javascript" src="../script/api.js"></script>
  <script type="text/javascript" src="../script/base.js"></script>
	<script>
apiready = function () {
    var fromwhattabs = api.pageParam.fromtabs;


    //
    var vm = new Vue({
      el:'#vm',
      data(){
        return{
          searname:'',
          tableData:[],
          isshowall:false,
          fromwhitetabs:'',

        }
      },
      created:function() {
        var that=this;


      },
      mounted:function(){
        var that=this;
        that.fromwhitetabs = fromwhattabs;
        that.getdata()
      },
      methods: {
        getdata:function(){
          let that=this;
          api.ajax({
            url:baseurl+'api/person/list',
            methods:'get',
            data:{
              values:{
                sec: $api.getStorage('apptoken')
              }
            }
          },function(ret,err){
            if(ret){
              api.hideProgress();
              // console.log(JSON.stringify(ret));
              if(ret.status == 1){
                that.tableData = ret.data.list;

              }else{
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
            }else{
              api.hideProgress();
              console.log(JSON.stringify(err));
              api.toast({
                  msg: err.msg,
                  duration: 3000,
                  location: 'bottom'
              });
            }
          })
        },
        //
        godesc:function(row, column, cell, event){
          // console.log(JSON.stringify(row));
          var that = this;
          if(that.fromwhitetabs=='1'){
            api.openWin({
                name: 'newpro1',
                url: './newpro1.html',
                pageParam: {
                    id: row.id,
                    isfromnew:true
                }
            });
          }else if(that.fromwhitetabs=='2'){
            api.openWin({
                name: 'newpro2',
                url: './newpro2.html',
                pageParam: {
                    id: row.id,
                    isfromnew:true
                }
            });
          }else if(that.fromwhitetabs=='3'){
            api.openWin({
                name: 'newpro3',
                url: './newpro3.html',
                pageParam: {
                    id: row.id,
                    isfromnew:true
                }
            });
          }else if(that.fromwhitetabs=='4'){
            api.openWin({
                name: 'newpro4',
                url: './newpro4.html',
                pageParam: {
                    id: row.id,
                    isfromnew:true
                }
            });
          }else if(that.fromwhitetabs=='5'){
            api.openWin({
                name: 'newpro5',
                url: './newpro5.html',
                pageParam: {
                    id: row.id,
                    isfromnew:true
                }
            });
          }


        },
        //搜索
        gosearch:function(){
          var that = this;
          if(that.searname == ''){
            api.toast({
                msg: '请输入要搜索的姓名',
                duration: 3000,
                location: 'bottom'
            });
          }else{
            that.oksear()
          }
        },
        //
        oksear:function(){
          let that=this;
          api.ajax({
            url:baseurl+'api/person/search',
            methods:'get',
            data:{
              values:{
                sec: $api.getStorage('apptoken'),
                key:that.searname
              }
            }
          },function(ret,err){
            if(ret){
              api.hideProgress();
              console.log(JSON.stringify(ret));
              if(ret.status == 1){
                that.tableData = ret.data.list;
                //显示返回全部按钮
                that.isshowall = true;
              }else{
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
            }else{
              api.hideProgress();
              console.log(JSON.stringify(err));
              api.toast({
                  msg: err.msg,
                  duration: 3000,
                  location: 'bottom'
              });
            }
          })
        },
      }
    })
	}


	</script>
</body>
</html>
